﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Implements;
using Newtonsoft.Json.Linq;

namespace Cofe.Web
{
    public static class IEntryJObjectSerializerExtension
    {
        public static CofeSystemInfo ReadLocalEntry(this IEntryJObjectSerializer serializer, JObject data, bool updateEntry)
        {
            if (updateEntry)
                return serializer.ReadEntry(data,
                    EntrySerializerHelpers.FindUsingParseName,
                    EntrySerializerHelpers.FindUsingId,
                    EntrySerializerHelpers.UpdateToCache);

            return serializer.ReadEntry(data,
                EntrySerializerHelpers.FindUsingParseName,
                EntrySerializerHelpers.FindUsingId);
        }

        public static WebEntryList ReadLocalEntryList(this IEntryJObjectSerializer serializer, JObject data, bool updateEntry)
        {
            if (updateEntry)
                return serializer.ReadEntryList(data,
                    EntrySerializerHelpers.FindUsingParseName,
                    EntrySerializerHelpers.FindUsingId,
                    EntrySerializerHelpers.UpdateToCache);

            return serializer.ReadEntryList(data,
                EntrySerializerHelpers.FindUsingParseName,
                EntrySerializerHelpers.FindUsingId);
        }



    }
}
